package com.affablebeans.model.repository;

import java.sql.SQLException;
import java.util.List;

import javax.sql.DataSource;

import com.affablebeans.model.bll.DefaultTrueValidator;
import com.affablebeans.model.bll.GenericEntityBLL;
import com.affablebeans.model.dal.OrderedProductDAL;
import com.affablebeans.model.entity.OrderedProduct;

/**
 * 
 * @author Bora SAYINER
 * @since Jan 26, 2015 11:58:22 PM
 * @version 1.0.0
 */
public class OrderedProducts {
	
	private final GenericEntityBLL<OrderedProduct> OrderedProductBLL;

	public OrderedProducts(DataSource dataSource) {
		OrderedProductDAL orderedProductDAL = new OrderedProductDAL(dataSource);
		DefaultTrueValidator<OrderedProduct> trueValidator = new DefaultTrueValidator<OrderedProduct>();
		this.OrderedProductBLL = new GenericEntityBLL<OrderedProduct>(orderedProductDAL, trueValidator);
	}

	public boolean insertOrderedProduct(OrderedProduct entity) throws SQLException {
		return OrderedProductBLL.insertEntity(entity);
	}

	public boolean updateOrderedProduct(OrderedProduct entity) throws SQLException {
		return OrderedProductBLL.updateEntity(entity);
	}

	public boolean deleteOrderedProduct(OrderedProduct entity) throws SQLException {
		return OrderedProductBLL.deleteEntity(entity);
	}

	public OrderedProduct findOrderedProductById(int id) throws SQLException {
		return OrderedProductBLL.findEntityById(id);
	}

	public List<OrderedProduct> getAllOrderedProducts() throws SQLException {
		return OrderedProductBLL.getAllEntities();
	}

	public int getCount() throws SQLException {
		return OrderedProductBLL.getEntitiesCount();
	}
}
